//
//  PKBaseNavigationController.swift
//  Panku
//
//  Created by mac on 2017/2/13.
//  Copyright © 2017年 Monster. All rights reserved.
//

import UIKit
import YYKit

class PKBaseNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        //不是根controller的时候 修改pop按钮
        if self.viewControllers.count != 0{
            
            //hide tabbar when push
            viewController.hidesBottomBarWhenPushed = true
            
            //设置pop按钮
            let popButton = PKBaseButton.createButton()
            popButton.addBlock(for: .touchUpInside) { (_) in
                //pop
                self.popViewController(animated: true)
            }
            popButton.frame = CGRect(x: 0, y: 0, width: 20, height: 20)
            popButton.setImage(R.image.nav_pop(), for: .normal)
            
            let popBarButtonItem = UIBarButtonItem(customView: popButton)
            viewController.navigationItem.leftBarButtonItem = popBarButtonItem

        }
        
        super.pushViewController(viewController, animated: true)
        
    }

}
